<html>
<head>
<title> Delete a staff for today</title>
<body>
<?php
if( isset( $_POST['staff_id'] ) ) {

	PutEnv("ORACLE_HOME=/usr/local/dbpackages/oracle");

	$c = oci_connect('comp231stu032', 'chemistry', 'comp231.cse.ust.hk');

	if(!$c) {
		echo "<p>Unable to connect:" . var_dump(oci_error($c));
		die();
	}

	//delete the staff from table form_1_team;
	$s = "delete from form_1_team where staff_id=$_POST[staff_id]";
	$q = oci_parse($c,$s);
	oci_execute($q);
	
	//delete the staff from table form_2_team;
	$s = "delete from form_2_team where driver_id=$_POST[staff_id]";
	$q = oci_parse($c,$s);
	oci_execute($q);

	//delete the staff from table driver;
	$s = "delete from driver where driver_id=$_POST[staff_id]";
	$q = oci_parse($c,$s);
	oci_execute($q);

	//delete the staff from table nondriver;
	$s = "delete from nondriver where id=$_POST[staff_id]";
	$q = oci_parse($c,$s);
	oci_execute($q);

	//delete the staff from table staff;
	$s1 = "delete from staff where ID = $_POST[staff_id]";	
	$q = oci_parse($c, $s1);
	oci_execute($q);

	echo "DONE";
	
}	
else {
	echo "
	<form action='delete.php' method='POST'>
	Staff ID: <input name='staff_id' maxlength='5' />
	<a href='index.php'><button type = 'submit'>Delete</a></button></a>
	<a href='index.php'><button type = 'reset'>Cancel</button></a><br>
	</form>";
}

?>
</body>
<html>

